<extend name="Public/usercenter"/>

<block name="body">
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/ext/chosen/chosen.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/ext/layer/layer.js"></script>
    <link href="__PUBLIC__/js/ext/chosen/chosen.min.css" type="text/css" rel="stylesheet">

    <legend>报告列表</legend>
    <div class="row">
        <div class="pull-right">
            请选择用户
            <select name="userId" class="form-control chosen" onchange="changeUser(this)">
                <option value="all">全部</option>
                <volist name="users" id="user">
                    <option value="{$user.id}" <eq name="user.id" value="$userId">selected</eq> >{$user.id} - {$user.nickname} </option>
                </volist>
            </select>
        </div>
    </div>
    <table class="table datatable">
        <thead>
        <tr>
            <th>#</th>
            <th>创建时间</th>
            <th>Uid</th>
            <th>病人</th>
            <th>图片</th>
            <th>pdf</th>
            <th>说明</th>
            <!--<th>操作</th>-->
        </tr>
        </thead>
        <tbody>
        <notempty name="list">
            <volist name="list" id="v">
                <tr>
                    <td><input type="checkbox" name="reportid[]" value="{$v.id}"></td>
                    <td>{$v.add_time|strtotime|date='m-d H:i:s',###}</td>
                    <td>{$v.user_id}</td>
                    <td>{$v.user_id|get_nickname}</td>
                    <td>
                        <php>
                            $pictures=explode(',',$v['pictures']);
                            $countP=count($pictures);
                        </php>
                        <foreach name="pictures" item="p" key="k">
                            <span data-url="__ROOT__{$p}" onmouseover="openImage(this)" data-title="{$p|basename}" class="icon-file-image"><!--{$p|basename}--></span>
                            <lt name="k" value="$coutP">
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            </lt>
                        </foreach>
                    </td>
                    <td>
                        <php>
                            $pdfs=explode(',',$v['pdfs']);
                            $countD=count($pdfs);
                        </php>
                        <foreach name="pdfs" item="pdf" key="k">
                            <a href="__ROOT__{$pdf}" target="_blank" class="icon-file-pdf"></a>
                            <lt name="k" value="$coutP">
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            </lt>
                        </foreach>
                    </td>
                    <td>{$v.content}</td>
                    <!--<td></td>-->
                </tr>
            </volist>
            <else />
            <tr><td colspan="7" align="center">暂无数据</td></tr>
        </notempty>
        </tbody>
    </table>
    <div class="row">
        {$page}
    </div>

    <script>
        $(function () {
            $('table.datatable').datatable();
        });
        function openImage(e) {
            layer.open({
                type: 2,
//               area: ['500px', '500px'],
                title: $(e).attr('data-title'),
                skin: 'layui-layer-rim', //加上边框
                content: [$(e).attr('data-url'), 'no']
            });
        }
        function changeUser(e) {
            console.log(location);
           var userId=$(e).val();
            var queryString='';
            var action = $(this).attr('action');
            if(action == '' || action ==null){
                action = location.href;
            }
            if (action.indexOf('?') > 0) {
                seperator = '?' ;
                action=action.split('?');
                action=action[0];
            } else {
                seperator = '?';
            }
            if(userId && userId!='all')
                queryString="userId="+ userId;
            else
                seperator='';

            var new_location = action + seperator +queryString;
            window.location.href = new_location;
        }
    </script>
</block>